# signals.py
from django.db.models.signals import post_save
from django.dispatch import receiver
from .sync_service import DataSyncService


@receiver(post_save, sender='es.TPADocument')
def sync_to_elasticsearch(sender, instance, created, **kwargs):
    sync_service = DataSyncService()
    sync_service.sync_single_document(
        instance.id,
        instance.problem
    )
